//why this is not work
chrome.extension.onRequest.addListener(
	 function(request, sender, sendResponse){		
		findItemAndSayhelloToExt();	
});


function clickItem(_item)
{
	if (document.createEvent)
                  {
                    var evObj = document.createEvent('MouseEvents');
                    evObj.initEvent( 'click', true, false );
                    _item.dispatchEvent(evObj);
                  }
                  else if (document.createEventObject)
                  {
                       _item.fireEvent('onclick');
                  }	
}

function findItemAndSayhelloToExt()
{
	//alert("find..");
	//var enditem = false;
	if($("#confirm_goods:visible").length>0){ 
		 clickItem(document.getElementById("confirm_goods"));
	} 
	else if($("#doSavePaymentButton:visible").length>0){  
		clickItem(document.getElementById("doSavePaymentButton"));
		window.setTimeout( function(){ findItemAndSayhelloToExt(); },1000 );
	} 
	else if($("#doSaveDeliveryBtn:visible").length>0){  
	    clickItem(document.getElementById("doSaveDeliveryBtn")); 
	    window.setTimeout( function(){ findItemAndSayhelloToExt(); },1000 );
	} 
	 
	var itemf = $(".login_form2").find("[class='btn ml74']").first();
	if(itemf.text()=="登　录" )
	{
		alert("login");
		itemf.click();
	}
	
}


function sayhello(){
	chrome.extension.sendRequest({greeting: "hello"}, function(response) {  
	if(response.doit == true)
	{
		
		findItemAndSayhelloToExt();
	}
	});
}

 sayhello();



